import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  getters: {
    GET_USERINFO: state => {
      return JSON.parse(localStorage.getItem('userInfo'))
    },
    GET_ROLES: state => {
      return localStorage.getItem('roles')
    },
    GET_TOKEN: state => {
      return localStorage.getItem('token')
    }
  },
  mutations: {
    SET_USERINFO: (state, userInfo) => {
      localStorage.setItem('userInfo', JSON.stringify(userInfo))
    },
    SET_ROLES: (state, roles) => {
      localStorage.setItem('roles', roles)
    },
    SET_TOKEN: (state, token) => {
      localStorage.setItem('token', token)
    }
  },
  actions: {
  },
  modules: {
  }
})
